package wcpackage.webapplication;

import org.apache.wicket.Request;
import org.apache.wicket.Session;
import org.apache.wicket.protocol.http.WebSession;
import wcpackage.domain.entities.User;

import java.util.Locale;

/**
 * User: rabbit
 * Date: Jun 11, 2009
 * Time: 12:29:01 PM
 */
public class UserSession extends WebSession {

    private User user;

    public UserSession(Request request, User user) {
        super(request);
        this.user = user;
    }

    public final boolean userIsAuthenticated() {
        return user != User.GUEST_USER;
    }

    public final static UserSession get() {
        return (UserSession) Session.get();
    }

    public final void setUser(User user) {
        this.user = user;
    }

    public final User getUser() {
        return user;
    }

    @Override
    public final Locale getLocale() {
        return new Locale("PL");
    }

    public final void logoutUser() {
        this.user = User.GUEST_USER;
    }

    public boolean isAuthenticated() {
        return user != User.GUEST_USER;
    }
}
